import codeJamUtils
import sys

def _compute_time(case):
    farmCost, farmRate, goal = case

    maxRate = 2
    prevTime = sys.maxsize
    curTime = goal / 2

    while curTime <= prevTime:
        prevTime = curTime

        # go back to before we went for goal
        curTime -= goal/maxRate
        # and this time go for another farm first
        curTime += farmCost / maxRate
        maxRate += farmRate
        curTime += goal / maxRate

    return prevTime



def _parse_input(inputLines):
    numCases = int(inputLines[0])
    cases = []
    for line in inputLines[1:]:
        farmCost, farmRate, goal = str.split(line)
        cases.append((float(farmCost), float(farmRate), float(goal)))
    return cases

if __name__ == "__main__":
    inputLines = codeJamUtils.get_input_lines("cookieClicker.txt")
    cases = _parse_input(inputLines)
    for i, case in enumerate(cases):
        codeJamUtils.write_output("cookieClicker.txt", i+1, _compute_time(case))

#In this problem, you start with 0 cookies. You gain cookies at a rate of 2 cookies 
#per second, by clicking on a giant cookie. Any time you have at least C cookies, 
#you can buy a cookie farm. Every time you buy a cookie farm, it costs you C cookies 
#and gives you an extra F cookies per second.

#Once you have X cookies that you haven't spent on farms, you win! Figure out how 
#long it will take you to win if you use the best possible strategy.